<!DOCTYPE html>
<html lang="en">
<head>
[#include "/customer/include/static.htm"]
    <link href="${path}/resources/plug/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    <script src="${path}/resources/plug/layui/layui.js" type="text/javascript"></script>
    <link href="${path }/resources/css/deal.css?v=2.5	" rel="stylesheet" type="text/css" />
</head>
<body>
<!--头部-->
[#include "/customer/include/header.ftl"]
<body>


<style>
    .layui-input layui-unselect{
    width: 95%;
    }

    .ketou {
        line-height: 30px;
        margin-top: 10px;
        font-size: 14px;
        color: #666;
    }

    .ketou span,.keyong span {
        line-height: 30px;
        font-size: 14px;
        color: #333;
    }

    .keyong {
        line-height: 30px;
        font-size: 14px;
        color: #666;
    }
    .p-w {
    width: 1200px;
    margin: auto;
    clear: both;
    background: #fff;
    padding-bottom: 20px;

</style>
<!--导航结束  -->
<div class="contain clearfix">
    <div class="w1002 top_title"><span class="fl"><a href="/Loan">理财投资列表</a>&gt;借款详情</span></div>

    <div class="m-under p-w">
        <div class="m_product">
         <form method="post" class="layui-form">
        <div class="m_product_lf">
          <h2 class="f18">${loan.name}</h2>
          <ul class="m_shou f14">
            <li class="w1">
                <i>借款年利率</i>
                <b>${loan.apr}
                    <span class="f14">%</span>
                </b>
            </li>
            <li class="w2"><i>项目期限</i><b>${loan.time_limit }
                       <span class="f14"> [#if loan.is_day==1 ]
                            天
                        [#else]
                            个月
                        [/#if]</span></b></li>
            <li>
                <i>项目金额</i>
                    <b>${currency(loan.account/10000)}
                        <span class="f14">万元</span>
                    </b>
            </li>
          </ul>
          <ul class="m_slif f16">
            <li>还款方式 : ${p2p_get_dict("borrow_style",loan.pay_style)} </li>
                <li>发布时间 : ${p2p_date_format(loan.first_verify_time,"yyyy-MM-dd HH:mm:ss") }</li>
            <li>起息日期：满标计息</li>
            <!--<li>截止日期：${p2p_date_format(loan.end_time,"yyyy-MM-dd HH:mm:ss") }</li>-->
          </ul>
        </div>
            <div class="m_rg m_rgw">
              <div class="m_kt f18">剩余可投：
                <span class="f24">${((loan.account-loan.amount_invested)/10000)}</span> 万
              </div>
              <dl class="m_sr f14">
                    <dt> 账户余额：[#if loginUser !=null ]
                        <font>${account.balance }</font>元
                    [#else]
                        <font>[<a href="${path }/member/common/login">请先登录</a>]
                        </font>
                    [/#if]</dt>

                <dd><input type="text" class="p2c_input" name="account"><span>元</span></dd>
                <dd>
                <select name="packet_id" id="packet_id" style=" style="width: 100%; height: 30px; margin:13px 0;" >
                                <option value="">--不使用红包--</option>
                                <option value="">--不使用红包--</option>

                                [#list redpackets as r]
                                <option value="${r.id}" >限定${r.tender_time_limit}月以上-${r.name}</option>
                                [/#list]
                     </select>
                </dd>
                <dd>
                    <input type="password" name="payPassword" style="width: 100%" required="" lay-verify="required" placeholder="请输入支付密码" autocomplete="off" class="layui-input">
                </dd>
                <dd class="layui-input-inline">
                     [#if loan.tbpwd?? && loan.tbpwd != '']
                                <input type="password" name="tbpwd"  required  lay-verify="required" placeholder="请输入定向密码" autocomplete="off" class="layui-input">
                        [/#if]
                </dd>
                <dd style="height:20px; line-height: 20px;">初始交易密码与登录密码一致,<a href="${path }/member/ucenter/deal">请尽快修改</a></dd>
              </dl>
              <div class="m_btun">
                    <a lay-submit="" lay-filter="MainForm" class="layui-btn" >立即投资</a>
                </div>
            </div>
            <input type="hidden" value="${loan.id}" id="loanId" name="loanId">
                        <input type="hidden" value="${token }" name="token"/>
        </form>
      </div>
    </div>
    <script type="text/javascript">
        var endTime =${last_time};
        var clearTime = null;
        function time() {


            var leftsecond = parseInt(endTime / 1000);


            var day = Math.floor(leftsecond/ (60 * 60 * 24)) < 0 ? 0 : Math.floor(leftsecond / (60 * 60 * 24));
            var hour = Math.floor((leftsecond - day * 24 * 60 * 60) / 3600) < 0 ? 0: Math.floor((leftsecond - day * 24 * 60 * 60) / 3600);
            var minute = Math.floor((leftsecond - day* 24 * 60 * 60 - hour * 3600) / 60) < 0 ? 0: Math.floor((leftsecond - day* 24 * 60 * 60 - hour * 3600) / 60);
            var second = Math.floor(leftsecond - day* 24 * 60 * 60 - hour * 3600- minute * 60) < 0 ? 0 : Math.floor(leftsecond - day * 24 * 60* 60 - hour * 3600 - minute* 60);
            if(hour<10)
            {
                hour="0"+hour;
            }
            if(minute<10)
            {
                minute="0"+minute;
            }
            if(second<10)
            {
                second="0"+second;
            }
            $("#tian").html("    ("+day+'天)');
            $(".time").html('<p class="orange mt10"><span class="details_bg">'+hour+'</span><span class="details_ico"></span><span class="details_bg">'+minute+'</span><span class="details_ico"></span><span class="details_bg">'+second+'</span><div class="clear"></div></p>');
            if (leftsecond <= 0) {
                clearInterval(clearTime);
                location.reload();
            }
        }

        clearTime = setInterval(function() {
            endTime = endTime - 1000;
            if(endTime<=0){
                $('#status2').hide();
                $('#status1').show();
                return ;
            }
            time();

        }, 1000);


    </script>

    <div class="plan_tab clearfix " id="loanmain">
        <ul>
            <li class="hover"><a  href="javascript:;" >项目介绍</a></li>
            <li><a  href="javascript:;">相关文件</a></li>
            <li><a  href="javascript:;">投标记录</a></li>

        </ul>
    </div>
    <div class="contain_main clearfix loandiv">

        <div class="pub_title pt10"><span class="fl">项目信息</span></div>
        <div class="plan_tab_con clearfix">
            <div style="word-wrap:break-word" class="mt15">借款描述：${loan.content }</div>
        </div>
    </div>

    <div class="contain_main clearfix loandiv" style="display: none">
    [@p2p_loan_img borrowId = loan.id]
        [#list tag_list as img]
            <li><img src="${img.img}" alt="" width="150px" /></li>
        [/#list]
    [/@p2p_loan_img]
    </div>

    <div class="contain_main clearfix loandiv" style="display: none">
        <div class="plan_tab_con01 clearfix">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tc">
                <tbody><tr class="leve_titbj">
                    <td width="330">序号</td>
                    <td width="156">投标人</td>
                    <td width="362">投标金额</td>
                    <td width="362">投标时间</td>
                </tr>
                [@p2p_loan_tender_list borrowId = loan.id]
                    [#list tag_list as borrowTender]
                    <tr>
                        <td>${borrowTender_index+1 }</td>
                        <td>*${borrowTender.username?substring(0,3)}**</td>

                        <td>￥${borrowTender.success_money }</td>
                        <td>${p2p_date_format(borrowTender.addtime,"yyyy-MM-dd HH:mm:ss") }</td>
                    </tr>
                    [/#list]
                [/@p2p_loan_tender_list]
                </tbody></table>
            <div>
                <div class="page"><a style="float: right;"  class="page-link">返回分页</a></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form(), $=layui.jquery, layer = layui.layer;
        form.on('submit(MainForm)', function(data){

            var lowest = Number('${loan.min_account}');
            var balance = Number('${account.balance}');

            if (balance <  data.field.account  ||  balance<=0) {
                layer.msg("您的余额不足，请充值");
                return false;
            }

            if (data.field.account < lowest && lowest > 0) {
                layer.msg("投标金额不能低于最小限额" + lowest + "元");
                return false;
            }

            var index = layer.load();
            ajax({
                url:"${path}/bid/tender",
                data: data.field,
                success: function(result){
                    if (result.type == "success") {
                        layer.msg(result.content,function(){  location.href ="${path}/bid/detail/${loan.id}"; });
                    } else {
                        layer.msg(result.content,{icon:2});
                    }
                    layer.close(index);
                },
                complete:function(){
                    layer.close(index);
                }
            });
            return false;
        });
    });
</script>
[#include "/customer/include/footer.ftl"]

</body>
</html>